//
//  CXRadioCollectionViewCell.m
//  XiMaFM
//
//  Created by hcios on 2017/9/2.
//  Copyright © 2017年 hcios. All rights reserved.
//

#import "CXStationCollectionViewCell.h"

@interface CXStationCollectionViewCell()

@property (nonatomic, strong) UIButton * button1;   //本地电台按钮

@property (nonatomic, strong) UIButton * button2;   //国家电台按钮

@property (nonatomic, strong) UIButton * button3;   //省市电台按钮

@property (nonatomic, strong) UIButton * button4;   //网络电台按钮

@end

@implementation CXStationCollectionViewCell

-(instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self.button1 cx_layoutButtonWithEdgeInsetsStyle: CX_ButtonEdgeInsetsStyleTop imageTitleSpace:5];
        [self.button2 cx_layoutButtonWithEdgeInsetsStyle: CX_ButtonEdgeInsetsStyleTop imageTitleSpace:5];
        [self.button3 cx_layoutButtonWithEdgeInsetsStyle: CX_ButtonEdgeInsetsStyleTop imageTitleSpace:5];
        [self.button4 cx_layoutButtonWithEdgeInsetsStyle: CX_ButtonEdgeInsetsStyleTop imageTitleSpace:5];
    }
    return self;
}




#pragma mark - 懒加载
-(UIButton *)button1 {
    if (!_button1) {
        _button1 = [UIButton buttonWithType:UIButtonTypeCustom];
        [self.contentView addSubview:_button1];
        [_button1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(10);
            make.top.bottom.mas_equalTo(0);
        }];
        [self.button1 setImage:[UIImage imageNamed:@"icon_radio_local"] forState:UIControlStateNormal];
        [self.button1 setTitle:@"本地台" forState:UIControlStateNormal];
        [_button1 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        _button1.titleLabel.font = [UIFont systemFontOfSize:15];
        _button1.tag = 1001;
        [_button1 addTarget:self action:@selector(didClickStationButton:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _button1;
}

-(UIButton *)button2 {
    if (!_button2) {
        _button2 = [UIButton buttonWithType:UIButtonTypeCustom];
        [self.contentView addSubview:_button2];
        [_button2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.button1.mas_right).mas_equalTo(10);
            make.top.bottom.mas_equalTo(0);
            make.size.mas_equalTo(self.button1);
        }];
        [self.button2 setImage:[UIImage imageNamed:@"icon_radio_country"] forState:UIControlStateNormal];
        [self.button2 setTitle:@"国家台" forState:UIControlStateNormal];
        [_button2 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        _button2.titleLabel.font = [UIFont systemFontOfSize:15];
        _button2.tag = 1002;
        [_button2 addTarget:self action:@selector(didClickStationButton:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _button2;
}

-(UIButton *)button3 {
    if (!_button3) {
        _button3 = [UIButton buttonWithType:UIButtonTypeCustom];
        [self.contentView addSubview:_button3];
        [_button3 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.button2.mas_right).mas_equalTo(10);
            make.top.bottom.mas_equalTo(0);
            make.size.mas_equalTo(self.button1);
        }];
        [self.button3 setImage:[UIImage imageNamed:@"icon_radio_province"] forState:UIControlStateNormal];
        [self.button3 setTitle:@"省市台" forState:UIControlStateNormal];
        [_button3 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        _button3.titleLabel.font = [UIFont systemFontOfSize:15];
        _button3.tag = 1003;
        [_button3 addTarget:self action:@selector(didClickStationButton:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _button3;
}

-(UIButton *)button4 {
    if (!_button4) {
        _button4 = [UIButton buttonWithType:UIButtonTypeCustom];
        [self.contentView addSubview:_button4];
        [_button4 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.button3.mas_right).mas_equalTo(10);
            make.right.mas_equalTo(-10);
            make.top.bottom.mas_equalTo(0);
            make.size.mas_equalTo(self.button1);
        }];
        [self.button4 setImage:[UIImage imageNamed:@"icon_radio_internet"] forState:UIControlStateNormal];
        [self.button4 setTitle:@"网络台" forState:UIControlStateNormal];
        [_button4 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        _button4.titleLabel.font = [UIFont systemFontOfSize:15];
        _button4.tag = 1004;
        [_button4 addTarget:self action:@selector(didClickStationButton:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _button4;
}


-(void)didClickStationButton:(UIButton *)button{
    if ([self respondsToSelector:@selector(didClickStationButton:)]) {
        [self.delegate didClickStationButton:button];
    }
}

@end
